﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Resources;
using System.Reflection;

namespace SvnCommitNotifier
{
    public partial class MonitorFoldersSettingForm : Form
    {
        public MonitorFoldersSettingForm()
        {
            InitializeComponent();
        }

        private void BtnAddFolder_Click(object sender, EventArgs e)
        {
            if (FolderBrowserDlg.ShowDialog() == DialogResult.OK)
            {
                var folder = FolderBrowserDlg.SelectedPath;
                if (!ListFolders.Items.Contains(folder))
                {
                    ListFolders.Items.Add(folder);
                    SvnWorkCopyMonitor.AddPath(folder);
                }
            }
        }

        private void BtnRemoveFolder_Click(object sender, EventArgs e)
        {
            if (ListFolders.SelectedIndex > -1)
            {
                if (MessageBox.Show("确定不再监视“" + ListFolders.SelectedItem + "”吗？", "确认删除", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    ListFolders.Items.Remove(ListFolders.SelectedItem);
                }
            }
        }

        private void BtnExit_Click(object sender, EventArgs e)
        {
            Dispose();
        }

        private void MainNotifyIcon_DoubleClick(object sender, EventArgs e)
        {
            Show();
            BringToFront();
        }

        private void MonitorFoldersSettingForm_SizeChanged(object sender, EventArgs e)
        {
            if (WindowState == FormWindowState.Minimized)
            {
                Hide();
            }
        }

        private void BtnMin_Click(object sender, EventArgs e)
        {
            Hide();
        }

        private void MonitorFoldersSettingForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            e.Cancel = true;
            MainNotifyIcon.Icon = Properties.Resources.warning;
        }
    }
}
